local ____lualib = require("lualib_bundle")
local __TS__New = ____lualib.__TS__New
local __TS__StringSplit = ____lualib.__TS__StringSplit
local __TS__Number = ____lualib.__TS__Number
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local __TS__SourceMapTraceBack = ____lualib.__TS__SourceMapTraceBack
__TS__SourceMapTraceBack(debug.getinfo(1).short_src, {["9"] = 1,["10"] = 1,["11"] = 2,["12"] = 2,["13"] = 4,["14"] = 4,["15"] = 5,["16"] = 5,["17"] = 6,["18"] = 6,["19"] = 7,["20"] = 7,["21"] = 8,["22"] = 8,["23"] = 11,["24"] = 13,["25"] = 13,["26"] = 13,["27"] = 14,["30"] = 17,["31"] = 18,["32"] = 19,["33"] = 20,["34"] = 22,["35"] = 23,["36"] = 23,["37"] = 23,["38"] = 24,["39"] = 24,["40"] = 24,["41"] = 24,["42"] = 25,["43"] = 27,["44"] = 23,["45"] = 23,["46"] = 30,["47"] = 30,["48"] = 30,["49"] = 30,["50"] = 31,["51"] = 13,["52"] = 13,["53"] = 11,["54"] = 36,["55"] = 37,["56"] = 37,["57"] = 37,["58"] = 38,["59"] = 40,["60"] = 41,["62"] = 43,["63"] = 37,["64"] = 37,["65"] = 46,["66"] = 36,["67"] = 49});
local ____exports = {}
local ____ui = require("kernel.util.ui")
local KUi = ____ui.default
local ____ui = require("data.ui.index")
local UI = ____ui.default
local ____event_util = require("kernel.util.event_util")
local EventUtil = ____event_util.default
local ____player = require("kernel.util.player")
local KPlayer = ____player.default
local ____player_group = require("kernel.util.player_group")
local KPlayerGroup = ____player_group.default
local ____HeroSelectController = require("app.ui.HeroSelectController")
local HeroSelectController = ____HeroSelectController.default
local ____AttackController = require("app.enemy.AttackController")
local InitAttack = ____AttackController.default
local function DifficultyLevelSelect()
    EventUtil:register(
        "TRIGGER_COMPONENT_EVENT",
        function(data)
            if data.__ui_event_name ~= "DifficultyLevelSelect" then
                return
            end
            local player = KPlayer:fromId(data.__role_id)
            local ui = __TS__New(KUi, data.__comp_name, player)
            local temps = __TS__StringSplit(ui.name, ".")
            local level = __TS__Number(temps[2] or 0)
            local list = KPlayerGroup:fromPlaying()
            __TS__ArrayForEach(
                list,
                function(____, target)
                    local currentDifficultyLevel = KUi:searchPath(
                        KPlayer:fromId(1),
                        UI.CurrentDifficultyLevel
                    )
                    currentDifficultyLevel:setText("难度" .. tostring(level))
                    HeroSelectController:fromPlayer(target)
                end
            )
            KUi:searchPath(
                KPlayer:fromId(1),
                UI.DifficultyLevel
            ):visible(false)
            InitAttack(nil)
        end
    )
end
local function InitUI()
    EventUtil:register(
        "GAME_INIT",
        function()
            local player = KPlayer:fromLocal()
            if player.id ~= 1 then
                KUi:searchPath(player, UI.DifficultyLevel):visible(false)
            end
            KUi:searchPath(player, UI.HeroSelect):visible(false)
        end
    )
    DifficultyLevelSelect(nil)
end
____exports.default = InitUI
return ____exports
